# Contributor: Carlo Bramini <carlo_bramini@users.sourceforge.net>

_realname=mxml
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.2
pkgrel=2
pkgdesc="A tiny XML library for reading and writing XML files (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://www.msweet.org/mxml/"
license=('Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
options=('strip' 'staticlibs')
source=("${_realname}-${pkgver}.tar.gz::https://github.com/michaelrsweet/${_realname}/archive/v${pkgver}.tar.gz"
         ${_realname}-${pkgver}.patch
         0001-autoconf-remove-options-for-clang.patch)
sha256sums=('1f9b2a2d0dd27915bf32124ca0c108ad4f4e0daba6d001ad10b6a6a97d0a1c24'
            '95f8947746e9ee5e7e7fb0b453bc0953e825c1ccf7559936f49b870a95f8c7f6'
            '27b86d6281cd9f7d1f4439bedb1fcd212e10cb954cfae07fe0d26447f50ebf6b')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  patch -p1 -i ${srcdir}/${_realname}-${pkgver}.patch
  patch -p1 -i ${srcdir}/0001-autoconf-remove-options-for-clang.patch
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"
  cp -a "../${_realname}-${pkgver}/." .

  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DSTROOT="${pkgdir}" install
}
